<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/8/13 0013
 * Time: 上午 10:11
 */
namespace app\admin\model;
use think\Model;
class Integral extends Model{

    public function user()
    {
        return $this->belongsTo('user','user_id');
    }
    /**
     * @param $id
     * @param string $relation
     * @return false|\PDOStatement|string|\think\Collection
     */
    public static function getlistrelation($relation,$where)
    {
        if(!$relation){
            $relation='user';
        }
        if(!$where){
             $where['status']=1;
        }
        return self::with($relation)->setEagerlyType(0);
    }

    /**
     * @param $value
     * @return string
     */
    public  function getITypeAttr($value)
    {
        switch ($value) {
            case 1:
                return '注册送积分';
                break;
            case 2:
                return '分享送积分';
                break;
            case 3:
                return '签到送积分';
                break;
            default;
                break;
        }
    }
}